package com.qf.service.impl;

import com.qf.pojo.User;
import com.qf.service.UserService;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

import java.util.ArrayList;
import java.util.List;

public class UserServiceImpl implements UserService , BeanPostProcessor {

    @Override
    public List<User> queryUsers() {
//        System.out.println("事务控制");
//        System.out.println("日志打印");
        System.out.println("queryUser");
        return new ArrayList<>();
    }
    
    @Override
    public Integer updateUser(User user) {
//        System.out.println("事务控制");
//        System.out.println("日志打印");
        System.out.println("update User");
//        if(1==1) {
//            throw new NullPointerException("test 空指针");
//        }
        return 1;
    }

    @Override
    public Integer saveUser(User user) {
//        System.out.println("事务控制");
//        System.out.println("日志打印");
        System.out.println("Save User");
        return 1;
    }

    @Override
    public Integer deleteUser(Integer id) {
//        System.out.println("事务控制");
//        System.out.println("日志打印");
        System.out.println("delete User");
        return 1;
    }

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {

        System.out.println("init方法之前执行");
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("init方法之后执行");
        return bean;
    }
}